#include <iostream>
#define N 10
#define M 5
float score[N][M];
float a_stu[N], a_cour[M];
int r, c;

int main() {
    int i, j;
    float h;
    void input_stu(void);
    void aver_stu(void);
    void aver_cour(void);
    float highest(void);
    float s_var(void);
    input_stu();
    aver_stu(); // 计算学生的平均成绩
    aver_cour(); //计算课程的平均成绩
    printf("\n  NO.\tcour1\tcour2\tcour3\tcour4\tcour5\taver\n");
    for (i = 0; i < N; i++) {
        printf("\n NO %2d", i + 1);
        for (j = 0; j < M; j++) {
            printf("%8.2f", score[i][j]);
        }
        printf("%8.2f\n", a_stu[i]);
    }
    printf("\naverage:");
    for (j = 0; j < M; j++) {
        printf("%8.2f", a_cour[j]);
    }
    printf("\n");
    h = highest();
    printf("highest: %7.2f\tNO. %2d\tcourse %2d\n", h, r, c);
    printf("variance %8.2f\n", s_var());
    return 0;
}

void input_stu(void) {
    int i, j;
    for(i = 0; i < N; i++) {
        printf("\ninput score of student%2d:\n", i+1);
        for (j = 0; j < M; j++) {
            scanf("%f", &score[i][j]);
        }
    }
}

void aver_stu(void) {
    int i, j;
    float s;
    for(i = 0; i < N; i++) {
        for(j = 0, s = 0; j < M; j++) {
            s += score[i][j];
        }
        a_stu[i] = s / 5.0;
    }
}

void aver_cour(void) {
    int i, j;
    float s;
    for (j = 0; j < M; j++) {
        s = 0;
        for (i = 0; i < N; i++) {
            s += score[i][j];
        }
        a_cour[j] = s / (float)N;
    }
}

float highest(void ) {
    float high;
    int i, j;
    high = score[i][j];
    for (i = 0; i < N; i++) {
        for (j = 0; j < M; j++) {
            if (score[i][j] > high) {
                high = score[i][j];
                r = i + 1;
                c = j + 1;
            }
        }
    }
    return (high);
}

float s_var(void) {
    int i;
     float sumx = 0.0, sumnx = 0.0;
     for (i = 0; i < N; i++) {
         sumx += a_stu[i] * a_stu[i];
         sumnx += a_stu[i];
     }
     return (sumx/N - (sumnx/N) * (sumnx/N));
}